package com.clearliang.netmodule.api;

import okhttp3.ResponseBody;
import retrofit2.adapter.rxjava.Result;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;
import rx.Observable;


/**
 * 各网络接口
 */
public interface ApiService {
    //https://raw.githubusercontent.com/facebook/react-native/0.51-stable/docs/MoviesExample.json
    //String API_SERVER_IP = "http://123.456.789.0:8080/";
    String API_SERVER_IP = "https://gitee.com/null_587_5980/";
    String API_SERVER_URL = API_SERVER_IP /*+ ""*/;

    //登陆
    @GET("api/login")
    Observable<ResponseBody> login(
            @Query("username") String username,
            @Query("password") String password,
            @Query("change_token") boolean isChangeToken
    );

    // 登陆
    /*@POST("client/login")
    Observable<UserBean> login(
            @Query("username") String username,
            @Query("password") String password
    );*/

    // 验证token
    @POST("client/token")
    Observable<ResponseBody> checkToken(
            @Query("token") String token
    );

    @GET("FrameWork/raw/master/app/src/main/movie.json")
    Observable<ResponseBody> getMovies(
    );

    /*获取到返回的Header和响应码的,用Observable<Result<T>> 代替 Observable<T>*/
    @GET("")
    Observable<Result<ResponseBody>> BlogService();

    @Streaming //大文件时要加不然会OOM
    @GET
    Observable<ResponseBody> downloadFile(
            @Url String fileUrl
    );


}
